package org.xt.module.api;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.QueryResult;
import org.nutz.dao.pager.Pager;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import org.xt.constants.Res;
import org.xt.entity.DataGangjia;

@IocBean
@At("/api/gangjia")
public class DataGangjiaApiModule {
	@Inject
	private Dao dao;
	
	@At("/list")
	@Ok("json")
	public Res list(@Param(value="page", df="1")int page, @Param(value="size", df="10")int size){
		Pager pager = dao.createPager(page, size);
		pager.setRecordCount(dao.count(DataGangjia.class, null));
		return Res.NEW()
				.code(Res.SUCCESS)
				.msg("ok")
				.data(new QueryResult(dao.query(DataGangjia.class, null, pager), pager));
	}
}
